package com.buddy.qreport.template.tpls.table.statistics;

import com.buddy.qreport.template.ReportDataDimension;
import com.buddy.qreport.template.IReportTemplate;
import com.buddy.qreport.template.annotation.ReportTemplate;
import com.buddy.qreport.template.tpls.ReportDisplayType;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 带统计的
 */
@ReportTemplate(type = IReportTemplate.TYPE_NAME_TABLE)
public class StatisticsTableIReportTemplate implements IReportTemplate {

    private final String demoJs;

    private final String optionJs;
    private List<ReportDataDimension> dataDimensions;

    public StatisticsTableIReportTemplate() {

        this.dataDimensions = Arrays.asList(
                new ReportDataDimension("横轴", "x",false),

                new ReportDataDimension("纵轴", "y",false),

                new ReportDataDimension("数据", "data",true)
        );


        demoJs =  new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("template/table/statistics/demo.js")))
                .lines().parallel().collect(Collectors.joining("\n"));

        optionJs =  new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("template/table/statistics/template.js")))
                .lines().parallel().collect(Collectors.joining("\n"));



    }

    @Override
    public ReportDisplayType getDisplayType() {
        return ReportDisplayType.TABLE;
    }

    @Override
    public String getDescription() {
        return "统计数据表格";
    }

    @Override
    public String getDemoJs() {
        return demoJs;
    }

    @Override
    public String getTemplateOptionJs() {
        return optionJs;
    }

    @Override
    public String getName() {
        return "statistics_table";
    }

    @Override
    public List<ReportDataDimension> getDataDimensions() {


        return dataDimensions;
    }
}
